/*
 * Server.h
 *
 *  Created on: Aug 11, 2012
 *      Author: nam20485
 */

#ifndef SERVER_H_
#define SERVER_H_

#include "IConnector.h"
#include "Connection.h"
#include "Message.h"

static const unsigned long MAX_CONNECTIONS = 5;

class Server
{
public:
	typedef void (*ServerReceiveHandler)(Connection::ID lClientID, const Message& message);

	Server(ServerReceiveHandler m_pfnReceiveHandler);
	virtual ~Server();

	Connection::ID Connect(IConnector& connector);
	bool Shutdown();

protected:
	unsigned long m_ulNextConnection;
	Connection* m_apConnections[MAX_CONNECTIONS];
	const ServerReceiveHandler m_pfnReceiveHandler;

	void OnConnectionReceive(Connection::ID lClientID, const Message& message);
};


#endif /* SERVER_H_ */
